﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.DataVisualization.Charting;
using Odds.Entity;
using Odds.DataAccess;
using System.Drawing;

public partial class Football_14Game_TrendOf310 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Chart1Bind();
        Chart2Bind();
        Chart3Bind();
    }

    private void Chart1Bind()
    {
        #region Create Series
        string[] strSeriesName = { "3", "1", "0", "4" };
        Color[] colorSeries = { Color.Green, Color.Blue, Color.Red, Color.Yellow };

        for (int i = 0; i < strSeriesName.Length; i++)
        {
            Chart1.Series.Add(new Series()
            {
                Name = strSeriesName[i],
                ChartType = SeriesChartType.Spline,
                Color = colorSeries[i],
                BorderWidth = 3,
                ShadowColor = Color.Black
            });
        }
        #endregion

        #region Create AxisY
        for (int i = 1; i < 15; i++)
        {
            Chart1.ChartAreas["ChartArea1"].AxisY.CustomLabels.Add(
                new CustomLabel()
                {
                    Text = i.ToString(),
                    FromPosition = 0.5 + i - 1,
                    ToPosition = 1.5 + i - 1,
                    GridTicks = GridTickTypes.All
                });
        }
        #endregion

        #region Create AxisX and Data
        List<Pro_TrendOf310Result> trendSet = new OddsSPController().GetTrendOf310();

        for (int i = 0; i < trendSet.Count; i++)
        {
            Chart1.Series["3"].Points.AddY(trendSet[i].Result3);
            Chart1.Series["1"].Points.AddY(trendSet[i].Result1);
            Chart1.Series["0"].Points.AddY(trendSet[i].Result0);
            Chart1.Series["4"].Points.AddY(trendSet[i].Cancel);
            Chart1.ChartAreas["ChartArea1"].AxisX.CustomLabels.Add(
                new CustomLabel()
                {
                    Text = trendSet[i].IssueRealID.ToString(),
                    FromPosition = 0.5 + i,
                    ToPosition = 1.5 + i,
                    GridTicks = GridTickTypes.All
                });
        }
        #endregion

        Chart1.ChartAreas["ChartArea1"].AxisX.IsMarginVisible = false;
        Chart1.ChartAreas["ChartArea1"].AxisX.LabelStyle.Angle = -90;
    }

    private void Chart2Bind()
    {

        List<Pro_TrendOfResultSumResult> trendSet = new OddsSPController().GetTrendOfResultSum();

        List<int> xValue = trendSet.OrderBy(s => s.IssueRealID).Select(s => s.IssueRealID).ToList();
        List<int> yValue = trendSet.OrderBy(s => s.IssueRealID).Select(s => s.ResultSum.Value).Distinct().ToList();


        foreach (Pro_TrendOfResultSumResult item in trendSet)
        {
            Chart2.Series[0].Points.AddXY(item.IssueRealID, item.ResultSum);
        }

        Chart2.Series[0].IsValueShownAsLabel = true;
        Chart2.ChartAreas["ChartArea1"].AxisY.IsStartedFromZero = false;
        Chart2.ChartAreas["ChartArea1"].AxisX.IsMarginVisible = false;
        Chart2.ChartAreas["ChartArea1"].AxisX.LabelStyle.Angle = -90;
        Chart2.ChartAreas["ChartArea1"].AxisX.IntervalAutoMode = IntervalAutoMode.VariableCount;

    }

    private void Chart3Bind()
    {
        string oddsCompanyID = "CE6CC998-22F4-4C01-8E4C-7AF2AD0F7E33";
        List<Pro_TrendOfOddsBeginSummaryResult> trendSet = new OddsSPController().GetTrendOfOddsBeginSummary(oddsCompanyID);
        
        List<int> xValue = trendSet.OrderBy(s => s.IssueRealID).Select(s => s.IssueRealID.Value).ToList();
        List<decimal> yValue = trendSet.OrderBy(s => s.IssueRealID).Select(s => s.OddsBeginSummary.Value).Distinct().ToList();


        foreach (Pro_TrendOfOddsBeginSummaryResult item in trendSet)
        {
            Chart3.Series[0].Points.AddXY(item.IssueRealID, item.OddsBeginSummary);
        }

        Chart3.Series[0].IsValueShownAsLabel = true;
        Chart3.ChartAreas["ChartArea1"].AxisY.IsStartedFromZero = false;
        Chart3.ChartAreas["ChartArea1"].AxisX.IsMarginVisible = false;
        Chart3.ChartAreas["ChartArea1"].AxisX.LabelStyle.Angle = -90;
        Chart3.ChartAreas["ChartArea1"].AxisX.IntervalAutoMode = IntervalAutoMode.VariableCount;
    }
}